import 'package:flutter/material.dart';
import 'package:flutter_rating_bar/flutter_rating_bar.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';

import '../config/config.dart';

Widget getMallHomeModule1(String imgUrl) {
  return Container(
    margin: EdgeInsets.only(top: 40.w, left: 25.w, right: 25.w),
    width: double.infinity,
    height: 300.w,
    child: ClipRRect(
      borderRadius: BorderRadius.circular(12.w),
      child: Image.network(
        imgUrl,
        fit: BoxFit.fill,
        width: double.infinity,
        height: double.infinity,
      ),
    ),
  );
}

Widget getMallHomeModule3(String imgUrl1, String imgUrl2, String imgUrl3) {
  return Container(
    margin: EdgeInsets.only(top: 40.w, left: 25.w, right: 25.w),
    decoration: const BoxDecoration(color: Colors.transparent),
    child: Column(
      crossAxisAlignment: CrossAxisAlignment.start,
      children: [
        Container(
          margin: const EdgeInsets.symmetric(vertical: 0, horizontal: 0),
          child: Row(
            children: [
              Text('活动专区',
                  style:
                      TextStyle(color: (Config.colorText1), fontSize: 30.sp)),
            ],
          ),
        ),
        Container(
          height: 320.w,
          margin: EdgeInsets.only(top: 20.w),
          child: Row(
            mainAxisAlignment: MainAxisAlignment.spaceBetween,
            children: [
              SizedBox(
                width: 222.w,
                height: double.infinity,
                child: ClipRRect(
                  borderRadius: BorderRadius.circular(12.w),
                  child: Image.network(
                    imgUrl1,
                    fit: BoxFit.fill,
                    width: double.infinity,
                    height: double.infinity,
                  ),
                ),
              ),
              SizedBox(
                width: 222.w,
                height: double.infinity,
                child: ClipRRect(
                  borderRadius: BorderRadius.circular(12.w),
                  child: Image.network(
                    imgUrl2,
                    fit: BoxFit.fill,
                    width: double.infinity,
                    height: double.infinity,
                  ),
                ),
              ),
              SizedBox(
                width: 222.w,
                height: double.infinity,
                child: ClipRRect(
                  borderRadius: BorderRadius.circular(12.w),
                  child: Image.network(
                    imgUrl3,
                    fit: BoxFit.fill,
                    width: double.infinity,
                    height: double.infinity,
                  ),
                ),
              ),
            ],
          ),
        ),
      ],
    ),
  );
}

Widget getMallHomeModule4(
    String imgUrl1, String imgUrl2, String imgUrl3, String imgUrl4) {
  return Container(
    margin: EdgeInsets.only(top: 40.w, left: 25.w, right: 25.w),
    decoration: const BoxDecoration(color: Colors.transparent),
    child: Column(
      crossAxisAlignment: CrossAxisAlignment.start,
      children: [
        Container(
          margin: const EdgeInsets.symmetric(vertical: 0, horizontal: 0),
          child: Row(
            children: [
              Text('积分专享',
                  style:
                      TextStyle(color: (Config.colorText1), fontSize: 30.sp)),
            ],
          ),
        ),
        Container(
          height: 170.w,
          margin: EdgeInsets.only(top: 20.w),
          child: Row(
            mainAxisAlignment: MainAxisAlignment.spaceBetween,
            children: [
              SizedBox(
                width: 342.w,
                height: double.infinity,
                child: ClipRRect(
                  borderRadius: BorderRadius.circular(12.w),
                  child: Image.network(
                    imgUrl1,
                    fit: BoxFit.fill,
                    width: double.infinity,
                    height: double.infinity,
                  ),
                ),
              ),
              SizedBox(
                width: 342.w,
                height: double.infinity,
                child: ClipRRect(
                  borderRadius: BorderRadius.circular(12.w),
                  child: Image.network(
                    imgUrl2,
                    fit: BoxFit.fill,
                    width: double.infinity,
                    height: double.infinity,
                  ),
                ),
              ),
            ],
          ),
        ),
        Container(
          height: 170.w,
          margin: EdgeInsets.only(top: 16.w),
          child: Row(
            mainAxisAlignment: MainAxisAlignment.spaceBetween,
            children: [
              SizedBox(
                width: 342.w,
                height: double.infinity,
                child: ClipRRect(
                  borderRadius: BorderRadius.circular(12.w),
                  child: Image.network(
                    imgUrl3,
                    fit: BoxFit.fill,
                    width: double.infinity,
                    height: double.infinity,
                  ),
                ),
              ),
              SizedBox(
                width: 342.w,
                height: double.infinity,
                child: ClipRRect(
                  borderRadius: BorderRadius.circular(12.w),
                  child: Image.network(
                    imgUrl4,
                    fit: BoxFit.fill,
                    width: double.infinity,
                    height: double.infinity,
                  ),
                ),
              ),
            ],
          ),
        ),
      ],
    ),
  );
}

Widget getMallHomeModule5(String imgUrl1, String imgUrl2, String imgUrl3,
    String imgUrl4, String imgUrl5) {
  return Container(
    margin: EdgeInsets.only(top: 40.w, left: 25.w, right: 25.w),
    decoration: const BoxDecoration(color: Colors.transparent),
    child: Column(
      crossAxisAlignment: CrossAxisAlignment.start,
      children: [
        Container(
          margin: const EdgeInsets.symmetric(vertical: 0, horizontal: 0),
          child: Row(
            children: [
              Text('大牌精选',
                  style:
                      TextStyle(color: (Config.colorText1), fontSize: 30.sp)),
            ],
          ),
        ),
        Container(
          height: 370.w,
          margin: EdgeInsets.only(top: 20.w),
          child: Row(
            mainAxisAlignment: MainAxisAlignment.spaceBetween,
            children: [
              SizedBox(
                width: 222.w,
                height: double.infinity,
                child: ClipRRect(
                  borderRadius: BorderRadius.circular(12.w),
                  child: Image.network(
                    imgUrl1,
                    fit: BoxFit.fill,
                    width: double.infinity,
                    height: double.infinity,
                  ),
                ),
              ),
              SizedBox(
                width: 222.w,
                height: double.infinity,
                child: Column(
                  mainAxisAlignment: MainAxisAlignment.spaceBetween,
                  children: [
                    SizedBox(
                      height: 176.w,
                      width: double.infinity,
                      child: ClipRRect(
                        borderRadius: BorderRadius.circular(12.w),
                        child: Image.network(
                          imgUrl2,
                          fit: BoxFit.fill,
                          width: double.infinity,
                          height: double.infinity,
                        ),
                      ),
                    ),
                    SizedBox(
                      height: 176.w,
                      width: double.infinity,
                      child: ClipRRect(
                        borderRadius: BorderRadius.circular(12.w),
                        child: Image.network(
                          imgUrl3,
                          fit: BoxFit.fill,
                          width: double.infinity,
                          height: double.infinity,
                        ),
                      ),
                    ),
                  ],
                ),
              ),
              SizedBox(
                width: 222.w,
                height: double.infinity,
                child: Column(
                  mainAxisAlignment: MainAxisAlignment.spaceBetween,
                  children: [
                    SizedBox(
                      height: 176.w,
                      width: double.infinity,
                      child: ClipRRect(
                        borderRadius: BorderRadius.circular(12.w),
                        child: Image.network(
                          imgUrl4,
                          fit: BoxFit.fill,
                          width: double.infinity,
                          height: double.infinity,
                        ),
                      ),
                    ),
                    SizedBox(
                      height: 176.w,
                      width: double.infinity,
                      child: ClipRRect(
                        borderRadius: BorderRadius.circular(12.w),
                        child: Image.network(
                          imgUrl5,
                          fit: BoxFit.fill,
                          width: double.infinity,
                          height: double.infinity,
                        ),
                      ),
                    ),
                  ],
                ),
              ),
            ],
          ),
        ),
      ],
    ),
  );
}

Widget getMallHomeModule6(String imgUrl1, String imgUrl2, String imgUrl3,
    String imgUrl4, String imgUrl5, String imgUrl6) {
  return Container(
    margin: EdgeInsets.only(top: 40.w, left: 25.w, right: 25.w),
    decoration: const BoxDecoration(color: Colors.transparent),
    child: Column(
      crossAxisAlignment: CrossAxisAlignment.start,
      children: [
        Container(
          margin: const EdgeInsets.symmetric(vertical: 0, horizontal: 0),
          child: Row(
            children: [
              Text('年中大促',
                  style:
                      TextStyle(color: (Config.colorText1), fontSize: 30.sp)),
            ],
          ),
        ),
        Container(
          height: 170.w,
          margin: EdgeInsets.only(top: 20.w),
          child: Row(
            mainAxisAlignment: MainAxisAlignment.spaceBetween,
            children: [
              SizedBox(
                width: 342.w,
                height: double.infinity,
                child: ClipRRect(
                  borderRadius: BorderRadius.circular(12.w),
                  child: Image.network(
                    imgUrl1,
                    fit: BoxFit.fill,
                    width: double.infinity,
                    height: double.infinity,
                  ),
                ),
              ),
              SizedBox(
                width: 342.w,
                height: double.infinity,
                child: ClipRRect(
                  borderRadius: BorderRadius.circular(12.w),
                  child: Image.network(
                    imgUrl2,
                    fit: BoxFit.fill,
                    width: double.infinity,
                    height: double.infinity,
                  ),
                ),
              ),
            ],
          ),
        ),
        Container(
          height: 160.w,
          margin: EdgeInsets.only(top: 16.w),
          child: Row(
            mainAxisAlignment: MainAxisAlignment.spaceBetween,
            children: [
              SizedBox(
                width: 342.w,
                height: double.infinity,
                child: Row(
                  mainAxisAlignment: MainAxisAlignment.spaceBetween,
                  children: [
                    SizedBox(
                      width: 162.w,
                      height: double.infinity,
                      child: ClipRRect(
                        borderRadius: BorderRadius.circular(12.w),
                        child: Image.network(
                          imgUrl3,
                          fit: BoxFit.fill,
                          width: double.infinity,
                          height: double.infinity,
                        ),
                      ),
                    ),
                    SizedBox(
                      width: 162.w,
                      height: double.infinity,
                      child: ClipRRect(
                        borderRadius: BorderRadius.circular(12.w),
                        child: Image.network(
                          imgUrl4,
                          fit: BoxFit.fill,
                          width: double.infinity,
                          height: double.infinity,
                        ),
                      ),
                    ),
                  ],
                ),
              ),
              SizedBox(
                width: 342.w,
                height: double.infinity,
                child: Row(
                  mainAxisAlignment: MainAxisAlignment.spaceBetween,
                  children: [
                    SizedBox(
                      width: 162.w,
                      height: double.infinity,
                      child: ClipRRect(
                        borderRadius: BorderRadius.circular(12.w),
                        child: Image.network(
                          imgUrl5,
                          fit: BoxFit.fill,
                          width: double.infinity,
                          height: double.infinity,
                        ),
                      ),
                    ),
                    SizedBox(
                      width: 162.w,
                      height: double.infinity,
                      child: ClipRRect(
                        borderRadius: BorderRadius.circular(12.w),
                        child: Image.network(
                          imgUrl6,
                          fit: BoxFit.fill,
                          width: double.infinity,
                          height: double.infinity,
                        ),
                      ),
                    ),
                  ],
                ),
              ),
            ],
          ),
        ),
      ],
    ),
  );
}

//返回今日推荐item
getListItem(String movieId, String imgurl, String title) {
  return InkWell(
    onTap: () {
      // Routes.navigateTo(context, Routes.movieDetail,
      //     params: {'movieId': movieId});
    },
    child: Container(
      padding: EdgeInsets.fromLTRB(10.w, 0, 10.w, 0),
      width: 300.w,
      child: Column(
        children: [
          ClipRRect(
            borderRadius: BorderRadius.circular(5),
            child: Image.network(
              imgurl,
              fit: BoxFit.fill,
              width: double.infinity,
              height: 275.w,
            ),
          ),
          const Padding(padding: EdgeInsets.all(2)),
          Text(
            title,
            softWrap: false,
            overflow: TextOverflow.ellipsis,
            style: TextStyle(color: (Config.colorText1), fontSize: 25.sp),
          ),
        ],
      ),
    ),
  );
}

Widget getMallHomeModuleToday() {
  return Container(
    margin: EdgeInsets.fromLTRB(0, 40.w, 0, 0),
    decoration: const BoxDecoration(color: Colors.transparent),
    child: Column(
      crossAxisAlignment: CrossAxisAlignment.start,
      children: [
        Container(
          margin: EdgeInsets.only(left: 30.w, right: 30.w, bottom: 25.w),
          child: Row(
            children: [
              // const Icon(Icons.local_fire_department, size: 20),
              // const SizedBox(width: 10, height: 10),
              Text('今日推荐',
                  style:
                      TextStyle(color: (Config.colorText1), fontSize: 30.sp)),
            ],
          ),
        ),
        SizedBox(
          width: double.infinity,
          height: 320.w,
          child: ListView.builder(
            itemCount: 5,
            padding: const EdgeInsets.symmetric(vertical: 0, horizontal: 5),
            shrinkWrap: true,
            scrollDirection: Axis.horizontal,
            physics: const BouncingScrollPhysics(),
            itemBuilder: (BuildContext context, int index) {
              return getListItem(
                  "WAHAHA",
                  "https://img.zcool.cn/community/01816558443778a801219c77f01608.jpg",
                  "WAHAHA");
            },
          ),
        ),
      ],
    ),
  );
}
